/*
 * @Author: ZephyrGao
 * @Date: 2024-06-12 17:11:55
 * @Description: 
 * Copyright (c) 2024 by ZephyrGao, All Rights Reserved. 
 */
// generateIconMap.js
const fs = require('fs');
const path = require('path');

// 图标库路径
const iconsPath = path.dirname(require.resolve('@ant-design/icons-vue/package.json'));

// 读取图标库中的所有图标
const iconFiles = fs.readdirSync(path.join(iconsPath, 'es/icons'));

// console.log(iconFiles)
// 生成映射表
const iconMap = iconFiles.reduce((map, file) => {
  const iconName = path.basename(file, '.js');
  map[iconName] = `() => import('@ant-design/icons-vue/es/icons/${iconName}')`;
  return map;
}, {});
console.log(iconMap)
// 生成映射表文件内容
const iconMapContent = `export default ${JSON.stringify(iconMap, null, 2).replace(/"(.+?)":/g, '$1:').replace(/"(\(\)\s=>\simport\(.+?\))"/g, '$1')};`;

// 写入映射表文件
fs.writeFileSync(path.join(__dirname, 'iconsMap.js'), iconMapContent);

console.log('Icon map generated successfully!');
